Example 7
|
extern int atoi(const char * /*nptr*/);which tries to convert the string given to an integer representation.
There is no integer to string routine, as the ISO/ANSI people probably expected you to simply
call printf(). However, if you are converting numbers to strings a lot, or if you do not
readily have access to printf() (if, for example, you are writing your code in assembler!)
then it can be a useful thing to have around.
Failing that, it is a good example...
Our stack does not need checking. We use the variable registers v1 (R4) and v2 (R5) as working registers, to pass information to ourself each time around. And as we BL, we must also store lr (R14). The largest number that can be represented by an unsigned 32 bit integer is 4294967295 which is ten digits in length. So ten digits multiplied by three registers is 30, which equates to 120 bytes. An APCS conformant language will guarantee you 256 bytes of stack space, so we do not have a problem here.
[... to be finished (why are you reading this!?) ...]